package com.fjp.heartguard.ui.userinfo.adapter

import android.widget.ImageView
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.fjp.heartguard.R
import com.fjp.heartguard.app.data.bean.CredentialFile
import com.fjp.heartguard.app.ext.setAdapterAnimation
import com.fjp.heartguard.app.util.SettingUtil


class CertificateAdapter(data: ArrayList<CredentialFile>, var clickItem: (index: Int,item: CredentialFile) -> Unit) : BaseQuickAdapter<CredentialFile, BaseViewHolder>(R.layout.item_certificate, data) {
    init {
        setAdapterAnimation(SettingUtil.getListMode())
    }

    override fun convert(holder: BaseViewHolder, item: CredentialFile) {
        if (item.file_url.toLowerCase().endsWith("png")) {
            holder.setImageResource(R.id.iconIv, R.drawable.certificate_icon_png)
        } else {
            holder.setImageResource(R.id.iconIv, R.drawable.certificate_icon_jpg)
        }

        holder.setText(R.id.nameTv, item.name)
        holder.setText(R.id.timeTv, item.time)
        holder.getView<ImageView>(R.id.editIv).setOnClickListener {
            clickItem(holder.bindingAdapterPosition,item)
        }
    }

}


